package com.ebelter.bodyfatscale.model;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.ebelter.bodyfatscale.R;
import com.ebelter.bodyfatscale.common.Constants;
import com.ebelter.bodyfatscale.ui.activity.AddUserInfoActivity;
import com.ebelter.bodyfatscale.ui.view.dialogs.TextTipDialog;
import com.ebelter.bodyfatscale.util.StringUtils;
import com.ebelter.bodyfatscale.util.UserSpUtil;
import com.ebelter.btlibrary.btble.common.Fields;
import com.ebelter.btlibrary.util.SpUtil;
import com.ebelter.btlibrary.util.ULog;

/**
 * 用户检测工具
 */
public class UserInfoCheckUtil {

    private static final String TAG = "UserInfoCheckUtil";

    //private TextTipDialog textTipDialog;
    /**
     * @return 检测的用户信息是否完整 true 信息完整 false信息不完整
     */
    public boolean startCheckUserInfo(){

        long usid=UserSpUtil.readLong(Constants.IUser.USER_ID);
        if (usid<=0){
            ULog.i(TAG,"用户id不正确，退出检测");
            return true;
        }

        String birthday=UserSpUtil.readString(Constants.IUser.BIRTHDAY);
        int sex=UserSpUtil.readInt(Constants.IUser.SEX,-1);
        int height=UserSpUtil.readInt(Constants.IUser.HEIGHT,-1);
        int profession=UserSpUtil.readInt(Constants.IUser.PROFESSION,-1);//角色类型

        if (TextUtils.isEmpty(birthday)||sex<0||height<0||profession<0){
            //说明信息不完整
            return false;
        }else {
            //说明信息完整
            return true;
        }



    }


//    private void disMissDialog() {
//        if (textTipDialog!=null){
//            if (textTipDialog.isShowing()) {textTipDialog.cancel();}
//            textTipDialog=null;
//        }
//    }
//
//    private void showDialog(final Activity activity) {
//        if (activity==null||activity.isDestroyed()||activity.isFinishing()){
//            return ;
//        }
//
//        if (textTipDialog!=null&&textTipDialog.isShowing()){
//            return;
//        }
//
//        textTipDialog=new TextTipDialog(activity, StringUtils.getResStr(R.string.adduserinfo_tip));
//        textTipDialog.setCanceledOnTouchOutside(false);
//
//        textTipDialog.setListener(new TextTipDialog.ICancelOkBtListener() {
//            @Override
//            public void cancel(Dialog dialogView) {
//                dialogView.cancel();
//            }
//
//            @Override
//            public void ok(Dialog dialogView) {
//                Intent intent = new Intent(activity, AddUserInfoActivity.class);
//                activity.startActivityForResult(intent,AddUserInfoActivity.REQUEST_CODE);
//                dialogView.cancel();
//
//            }
//        });
//        textTipDialog.show();
//        textTipDialog.setNativebtVisibility(View.GONE);
//
//
//
//    }


}
